package com.great.web.action;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.great.model.pojo.UserInfo;
import com.great.model.pojo.WebInfo;
import com.great.service.IUserInfoService;
import com.great.service.IWebInfoService;
import com.opensymphony.xwork2.ActionSupport;

@Controller
public class adminAction extends BaseAction{
	private UserInfo userInfo;
	private WebInfo webInfo;
	private String selectstr;
	private Map<String, Object> info;
	@Resource
	private IUserInfoService UserInfoService;
	@Resource
	private IWebInfoService webInfoService;
	
	public String adduser() {
		try {
			UserInfoService.sAddUser(userInfo);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	public String selectuser() {
		List<UserInfo> userInfos=null;
		try {
			userInfos=UserInfoService.sSelectUser(selectstr);
			session.put("alluser",userInfos);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	public String setuser() {
		List<UserInfo> userInfos=null;
		try {
			UserInfoService.sUpdataUser(userInfo);
			userInfos=UserInfoService.sSelectUser("");
			session.put("alluser",userInfos);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}
	public String deleteuser() {
		List<UserInfo> userInfos=null;
		try {
			UserInfoService.sDeleteUser(userInfo);
			userInfos=UserInfoService.sSelectUser("");
			session.put("alluser",userInfos);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}
	public String addweb() {
		try {
			webInfoService.sAddWeb(webInfo);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	
	public String selectwebbyname() {
		List<WebInfo> webInfos=null;
		try {
			webInfos=webInfoService.sSelectWebByName(selectstr);
			session.put("allweb",webInfos);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	public String selectwebbybigtype() {
		List<WebInfo> webInfos=null;
		try {
			webInfos=webInfoService.sSelectWebByBigType(selectstr);
			session.put("allweb",webInfos);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	public String selectwebbytype() {
		List<WebInfo> webInfos=null;
		try {
			webInfos=webInfoService.sSelectWebByType(selectstr);
			session.put("allweb",webInfos);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	public String setweb() {
		List<WebInfo> webInfos=null;
		try {
			webInfoService.sUpdataWeb(webInfo);
			webInfos=webInfoService.sSelectWebByName("");
			session.put("allweb",webInfos);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}
	public String deleteweb() {
		List<WebInfo> webInfos=null;
		try {
			webInfoService.sDeleteWeb(webInfo);
			webInfos=webInfoService.sSelectWebByName("");
			session.put("allweb",webInfos);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}
	
	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

	public IUserInfoService getUserInfoService() {
		return UserInfoService;
	}

	public void setUserInfoService(IUserInfoService userInfoService) {
		UserInfoService = userInfoService;
	}
	public String getSelectstr() {
		return selectstr;
	}
	public void setSelectstr(String selectstr) {
		this.selectstr = selectstr;
	}
	public WebInfo getWebInfo() {
		return webInfo;
	}
	public void setWebInfo(WebInfo webInfo) {
		this.webInfo = webInfo;
	}
	public Map<String, Object> getInfo() {
		return info;
	}
	public void setInfo(Map<String, Object> info) {
		this.info = info;
	}
	public IWebInfoService getWebInfoService() {
		return webInfoService;
	}
	public void setWebInfoService(IWebInfoService webInfoService) {
		this.webInfoService = webInfoService;
	}
	
}
